package com.tokenplus.thai.aviewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.tokenplus.thai.adata.income.ReqExtractInviteIncome
import com.tokenplus.thai.adata.income.ReqGetInviteIncomeData
import com.tokenplus.thai.base.BaseViewModel
import com.tokenplus.thai.anetwork.ApiUserReposity

class IncomeViewModel : BaseViewModel() {

    ///////////////////////////////////////////
    var canWithdrawAmount: String? = null

    //////////////////////////////////////////
    private val mExtractInviteIncomeLiveData = MutableLiveData<ReqExtractInviteIncome>()

    val onExtractInviteIncomeLiveData =
        Transformations.switchMap(mExtractInviteIncomeLiveData) { query ->
            ApiUserReposity.extractInviteIncome(this, query)
        }

    fun extractInviteIncome(reqExtractInviteIncome: ReqExtractInviteIncome) {
        mExtractInviteIncomeLiveData.value = reqExtractInviteIncome
    }

    //////////////////////////////////////////
    private val mExtractRechargeIncomeLiveData = MutableLiveData<ReqExtractInviteIncome>()

    val onExtractRechargeIncomeLiveData =
        Transformations.switchMap(mExtractRechargeIncomeLiveData) { query ->
            ApiUserReposity.extractRechargeIncome(this, query)
        }

    fun extractRechargeIncome(reqExtractInviteIncome: ReqExtractInviteIncome) {
        mExtractRechargeIncomeLiveData.value = reqExtractInviteIncome
    }

    //////////////////////////////////////////
    private val mGetInviteIncomeDataLiveData = MutableLiveData<ReqGetInviteIncomeData>()

    val onGetInviteIncomeDataLiveData =
        Transformations.switchMap(mGetInviteIncomeDataLiveData) { query ->
            ApiUserReposity.getInviteIncomeData(this, query)
        }

    fun getInviteIncomeData(reqGetInviteIncomeData: ReqGetInviteIncomeData) {
        mGetInviteIncomeDataLiveData.value = reqGetInviteIncomeData
    }

    //////////////////////////////////////////
    private val mGetRechargeIncomeDataLiveData = MutableLiveData<ReqGetInviteIncomeData>()

    val onGetRechargeIncomeDataLiveData =
        Transformations.switchMap(mGetRechargeIncomeDataLiveData) { query ->
            ApiUserReposity.getRechargeIncomeData(this, query)
        }

    fun getRechargeIncomeData(reqGetInviteIncomeData: ReqGetInviteIncomeData) {
        mGetRechargeIncomeDataLiveData.value = reqGetInviteIncomeData
    }
}